#ifndef DATAANALYSE_H
#define DATAANALYSE_H

#include "analyse.h"
#include <QObject>
#include <QDebug>
#include <tuple>
#include <vector>

class dataanalyse : public QObject
{
    Q_OBJECT
public:
    explicit dataanalyse(QObject *parent = nullptr);

    //保存衰减结果
    QList<double> resshuaijian;
    //保存滤波结果
    QList<double> reslvbo;
    //保存扩增结果
    QList<double> reslvkuozeng;

    //实例化数据分析类
    Analyse *ana ;


    //荧光原始数据源
    QList<QList<QHash<QString, QString>>> saveYingguangDataList;

    //解析原始荧光数据方法
    QList<int> PROCparseYingguang(QList<QList<QHash<QString, QString>>> saveYingguangDataList);


    //荧光衰减计算（单孔单通道）
    QList<double> PROCYingguangshuaijian(QList<int> singleYingguang, int shuaijianType);
    //滤波计算（单孔单通道）
    QList<double> PROCYingguanglvbo(QList<double> singleYingguang, int lvboType);
    //扩增计算（单孔单通道）
    QList<double> PROCYingguangkuozeng(QList<double> singleYingguang);
    //数据分析（单孔单通道）
    QList<double> PROCshujufenxidan(QList<int> singleYingguang,int shuaijian,int CtType,
                                    QHash<QString, int> baseline, double yuzhi, int shuaijianType, int lvboType, int NL,int sigmodType);
    //阈值/ct值计算(返回阈值)
    QList<QList<double>> PROCyuzhi(QList<double> singleYingguang, int CT, QHash<QString, int> baseline, double yuzhi, int NL, int sigmodType);


    //解析原始荧光数据
    QList<QList<QHash<QString, QString>>> PROCYingguang(QList<QList<QHash<QString, QString>>> saveYingguangDataList);
    //生成原始数据方法
    QList<QList<QHash<QString, QString>>> PROCshengcheng(int len);
    //拆解原始数据方法（从原始数据拆解为单孔单通道）
    QList<QList<QHash<int, QHash<int, int>>>> PROCchaijie(QList<QList<QHash<QString, QString>>> yingguangdata);
    //拆解新组成的数据，并返回数据分析格式
    QList<QHash<int, QList<double>>> PROCparseData(QList<QList<QHash<int, QHash<int, int>>>> data,int shuaijian,int CtType, QList<QHash<QString, int>> baseline, double yuzhi1, double yuzhi2, double yuzhi3, double yuzhi4,int shuaijianType, int lvboType, int NL, int sigmodeType);

    //将数据分析后的数据拆分并组合
    //QList<QList<QHash<QString, QString>>> PROCzuheData(QList<QHash<int, QList<double>>> data);
    std::tuple<QList<QList<QHash<QString, QString>>> ,QList<double>,QList<QHash<QString, QString>>> PROCzuheData(QList<QHash<int, QList<double>>> data);


    //最终方法封装：荧光，ct，阈值

    ///
    /// \brief dataanalyse::PROCDataAnalyse 数据分析方法封装
    /// \param data      原始荧光值
    /// \param shuaijian 是否衰减 0-关，1-开
    /// \param CtType    ct值计算方法 0-sigmoid，1-交叉，2-普通
    /// \param start     baseline["start"]
    /// \param end       baseline["end"]
    /// \param yuzhi1    通道1阈值 double型 默认0.0
    /// \param yuzhi2    通道2阈值 double型 默认0.0
    /// \param yuzhi3    通道3阈值 double型 默认0.0
    /// \param yuzhi4    通道4阈值 double型 默认0.0
    /// \return        元组<数据分析后的荧光值，ct值（键值对能对应孔位）， 阈值>
    ///
    std::tuple<QList<QList<QHash<QString, QString>>> ,QList<double>,QList<QHash<QString, QString>>> PROCDataAnalyse(QList<QList<QHash<QString, QString>>> yingguangdata,int shuaijian,int CtType,QList<QHash<QString, int>> baseline, double yuzhi1, double yuzhi2, double yuzhi3, double yuzhi4
                                                                                                                    ,int shuaijianType, int lvboType, int NL, int sigmodType);

signals:

public slots:
};

#endif // DATAANALYSE_H
